<div class="custom">
    <h1>
        采购单
    </h1>
    <form class="row form-inline" >
        <div class="form-group col-md-4">
            <label class="">采购单号</label>
            <input class=" form-control" type="number" ng-model="queryData.purchaseOrderId" placeholder="采购单号" value="queryData.purchaseOrderId">
        </div>
        <div class="form-group col-md-4">
            <label class="">开始日期</label>
            <input class=" form-control" type="date" ng-model="queryData.ctime_tstart  " placeholder="开始日期" value="queryData.ctime_tstart | date:'yyyy-MM-dd'">
        </div>
        <div class="form-group col-md-4">
            <label class="">截止日期</label>
            <input class=" form-control" type="date" ng-model="queryData.ctime_tend" placeholder="截止日期" value="queryData.ctime_tend | date:'yyyy-MM-dd'">
        </div>
        <div class="form-group col-md-2" style="margin-top:10px;margin-bottom:10px;">
            <button type="button" class="btn btn-warning btn-block" ng-click="doQuery(queryData.purchaseOrderId);" >查询</button>
        </div>
        <div class="form-group col-md-2" style="margin-top:10px;margin-bottom:10px;">
            <button type="reset"  class="btn btn-default" ng-click="reset()">重置</button>
        </div>
    </form>
    <div ng-if="data.isShowDetail">

        <div class="panel panel-default" >

            <div class="panel-heading clearfix">
                采购单号：{{data.purchaseOrderId}}
                <div class="btn-group pull-right" role="group" aria-label="...">
                    <button type="button" class="btn btn-default btn-sm" ng-click="data.isShowDetail=false;">收起</button>
                </div>
            </div>

            <table class="table table-bordered panel-body table-hover table-condensed ">

                <thead>
                <tr>
                    <th width="15%">订单详情id</th>
                    <th width="15%">商品名称</th>
                    <th width="15%">数量</th>
                    <th width="20%">进价</th>
                    <th width="20%">售价</th>
                    <th width="20%">操作</th>
                </tr>
                </thead>

                <tbody>
                <tr ng-repeat="item in purchaseOrderrDetailList" >
                    <td>{{item.purchaseOrderDetailId}}</td>
                    <td>{{item.commodityName}}</td>
                    <td>{{item.number}}</td>
                    <td><input type="number" ng-model="item.curPrice"></td>
                    <td><input type="number" ng-model="item.outPrice"></td>
                    <td><button class="btn btn-warning btn-xs" type="button" ng-click="curPriceUpdate(item.purchaseOrderDetailId,item.curPrice,item.outPrice)">确认修改</button></td>
                    <!--<td ng-switch="data.purchaseOrderStatus"><span ng-switch-when="1">{{item.curPrice}}</span><input type="number" ng-model="item.curPrice" ng-blur="curPriceUpdate(item.purchaseOrderDetailId,item.curPrice)" ng-switch-when="0"></td>-->
                    <!--<td ng-switch="data.purchaseOrderStatus"><span ng-switch-when="1">{{item.outPrice}}</span><input type="number" ng-model="item.outPrice" ng-blur="outPriceUpdate(item.purchaseOrderDetailId,item.outPrice)" ng-switch-when="0"></td>-->
                </tr>
                </tbody>

            </table>

        </div>


    </div>
    <div class="panel panel-default">
        <div class="panel-heading clearfix">
            采购单列表
        </div>

        <table class="table table-bordered panel-body table-condensed">
            <thead>
            <tr>
                <th width="10%">#</th>
                <th width="10%">采购单号</th>
                <th width="20%">状态</th>
                <th width="20%">时间</th>
                <th width="30%">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="item in list">
                <th>
                    {{$index+1}}
                </th>
                <th>
                    {{item.purchaseOrderId}}
                </th>
                <th>
                    {{item.purchaseOrderStatus | status}}</span>
                </th>
                <th>
                    {{item.ctime}}
                </th>
                <td ng-switch="item.purchaseOrderStatus">
                    <a ui-sref="admin.lineOrder({id:item.purchaseOrderId})" class="btn btn-xs btn-default">明细</a>
                    <!--<a ng-click="queryPurchaseDetail(item.purchaseOrderId,item.purchaseOrderStatus);" class="btn btn-xs btn-default">修改价格</a>-->
                    <a ui-sref="purchasePrint({id:item.purchaseOrderId})" class="btn btn-xs btn-default">打印</a>
                    <a ui-sref="purchasePrint({id:item.purchaseOrderId,Soring:1})" class="btn btn-xs btn-default">打印分拣单</a>
                <a ng-click="procurementCompletion(item.purchaseOrderId);" ng-switch-when="1" class="btn btn-xs btn-success">采购完成</a>
                </td>
            </tr>
            </tbody>
        </table>

        <div class="panel-footer" style="text-align: center;">
            <uib-pagination style="margin:0;" ng-change="pageChanged(page.currentPage)" total-items="page.totalSize" ng-model="page.currentPage"
                            items-per-page="page.pageSize" max-size="5" class="pagination-sm" boundary-links="true"
                            rotate="false"></uib-pagination>
        </div>
    </div>

</div>